<style>
    .layui-laypage,
    .pagination {
        transform: translateX(-50%);
        margin-left: 50%;
    }
</style>
<div class="fly-panel fly-column">
    <div class="layui-container">
        <ul class="layui-clear">
            <li class="layui-hide-xs {$cateid == '' ? 'layui-this' : ''}"><a href="{:url('/')}">首页</a></li>
            {foreach $CateList as $item}
            <li class="{$cateid == $item.id ? 'layui-this' : ''}">
                <a
                    href="{:url('home/index/index',['cateid' => $item.id,'accept' => $accept,'state' => $state])}">{$item.name}</a>
            </li>
            {/foreach}

            <li class="layui-hide-xs layui-hide-sm layui-show-md-inline-block"><span class="fly-mid"></span></li>

            <!-- 用户登入后显示 -->

            {if condition="$LoginUser"}
            <li class="layui-hide-xs layui-hide-sm layui-show-md-inline-block">
                <a href="{:url('home/user/collect',['collect'=>'collected'])}">我发表的贴</a>
            </li>
            <li class="layui-hide-xs layui-hide-sm layui-show-md-inline-block">
                <a href="{:url('home/user/collect',['collect'=>'collection'])}">我收藏的贴</a>
                <!-- <a href="user/index.html#collection">我收藏的贴</a> -->
            </li>
            {/if}
        </ul>

        <div class="fly-column-right layui-hide-xs">
            <span class="fly-search"><i class="layui-icon"></i></span>
            <a href="{:url('home/post/add')}" class="layui-btn">发表新帖</a>
        </div>
        <div class="layui-hide-sm layui-show-xs-block"
            style="margin-top: -10px; padding-bottom: 10px; text-align: center;">
            <a href="{:url('home/post/add')}" class="layui-btn">发表新帖</a>
        </div>
    </div>
</div>

<div class="layui-container">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md8">

            <div class="fly-panel" style="margin-bottom: 0;">

                <div class="fly-panel-title fly-filter">
                    <a href="{:url('home/index/index',['state' => '','cateid'=>$cateid,'accept' => $accept])}"
                        class="{$state == '' ? 'layui-this':''}">全部</a>
                    <span class="fly-mid"></span>
                    <a href="{:url('home/index/index',['state' => 1,'cateid'=>$cateid,'accept' => $accept])}"
                        class="{$state == 1 ? 'layui-this':''}">置顶</a>
                    <span class="fly-mid"></span>
                    <a href="{:url('home/index/index',['state' => 2,'cateid'=>$cateid,'accept' => $accept])}"
                        class="{$state == 2 ? 'layui-this':''}">精华</a>
                    <span class="fly-mid"></span>
                    <a href="{:url('home/index/index',['state' => 3,'cateid'=>$cateid,'accept' => $accept])}"
                        class="{$state == 3 ? 'layui-this':''}"> 热门</a>
                    <span class="fly-filter-right layui-hide-xs">

                        <a href="{:url('home/index/index',['accept' => 1,'state'=>$state,'cateid' => $cateid])}"
                            class="{$accept == 1 ? 'layui-this' : ''}">已采纳</a>
                        <span class="fly-mid"></span>
                        <a href="{:url('home/index/index',['accept' => 0,'state'=>$state,'cateid' => $cateid])}"
                            class="{$accept == 0 ? 'layui-this' : ''}">未采纳</a>
                    </span>
                </div>

                <ul class="fly-list">
                    {foreach $PostList as $item}
                    <li>
                        <a href="{:url('home/user/index',['userid' => $item.user.id])}" class="fly-avatar">
                            <img src="{$item.user.avatar_cdn}" alt="{$item.user.nickname}">
                        </a>
                        <h2>
                            <a class="layui-badge">{$item.cate.name}</a>
                            <a href="{:url('home/index/info',['postid' => $item.id])}">{$item.title}</a>
                        </h2>
                        <div class="fly-list-info">
                            <a href="{:url('home/index/index',['userid' => $item.user.id])}" link>
                                <cite>{$item.user.nickname}</cite>
                                <i class="iconfont icon-renzheng" title="认证信息：{$item.user.nickname}"></i>
                                <i class="layui-badge fly-badge-vip">VIP {$item.user.vip}</i>
                            </a>
                            <span>{$item.createtime}</span>

                            <span class="fly-list-kiss layui-hide-xs" title="悬赏飞吻"><i class="iconfont icon-kiss"></i>
                                {$item.point}</span>
                            {if condition="$item.accept"}
                            <span class="layui-badge fly-badge-accept layui-hide-xs">已结</span>
                            {/if}
                            <span class="fly-list-nums">
                                <i class="iconfont icon-pinglun1" title="回答"></i> {$item.comment_count}
                            </span>
                        </div>
                        <div class="fly-list-badge">
                            {if condition="$item.state == 1"}
                            <span class="layui-badge layui-bg-red">置顶</span>
                            {elseif condition='$item.state == 2'}
                            <span class="layui-badge layui-bg-red">精华</span>
                            {elseif condition='$item.state == 3'}
                            <span class="layui-badge layui-bg-red">热门</span>
                            {/if}
                        </div>
                    </li>
                    {/foreach}
                </ul>
                {$PostList->render()}
                <!-- <div style="text-align: center">
                    <div class="laypage-main">
                        <a href="jie/index.html" class="laypage-next">更多求解</a>
                    </div>
                </div> -->

            </div>
        </div>
        <div class="layui-col-md4">

            <div class="fly-panel fly-signin">
                <div class="fly-panel-title">
                    签到
                    <i class="fly-mid"></i>
                    <a href="javascript:;" class="fly-link" id="LAY_signinHelp">说明</a>
                    <i class="fly-mid"></i>
                    <a href="javascript:;" class="fly-link" id="LAY_signinTop">活跃榜<span
                            class="layui-badge-dot"></span></a>
                    <span class="fly-signin-days">已连续签到<cite>{$LoginUser["sign_time"]["num"] ?
                            $LoginUser["sign_time"]["num"] : 0}</cite>天</span>
                </div>
                <div class="fly-panel-main fly-signin-main">
                    {php}$nowTime = strtotime(date('Y-m-d 0:0:0', time()));{/php}
                    {php}$signTime = !empty($LoginUser["sign_time"]["signTime"]) ? $LoginUser["sign_time"]["signTime"] :
                    0;{/php}
                    {if condition='$signTime != $nowTime'}
                    <button class="layui-btn layui-btn-info" id="LAY_signin">今日签到</button>
                    <span class="fly-kiss">可获得<cite id="fly-kiss">{$SignPoint}</cite>飞吻</span>
                    {else /}
                    <button class="layui-btn layui-btn-disabled">今日已经签到成功</button>
                    {/if}
                </div>
            </div>

            <div class="fly-panel">
                <h3 class="fly-panel-title">本周热议</h3>
                <ul class="fly-panel-main fly-list-static">
                    {foreach $HotPostList as $item}
                    <li>
                        <a href="{:url('home/index/info',['postid' => $item.post.id])}">{$item.post.title}</a>
                    </li>
                    {/foreach}

                </ul>
            </div>

            <div class="fly-panel fly-rank fly-rank-reply" id="LAY_replyRank">
                <h3 class="fly-panel-title">回贴周榜</h3>
                <dl>
                    <!--<i class="layui-icon fly-loading">&#xe63d;</i>-->
                    {foreach $HotUserList as $item}
                    <dd>
                        <a href="{:url('home/user/index',['userid' => $item.user.id])}">
                            {if condition="!empty($item.user.avatar)"}
                            <img src="{$item.user.avatar}"><cite>{$item.user.nickname}</cite><i>{$item.num}次回答</i>
                            {else /}
                            <img
                                src="/static/home/res/images/avatar/1.jpg"><cite>{$item.user.nickname}</cite><i>{$item.num}次回答</i>
                            {/if}
                        </a>
                    </dd>
                    {/foreach}
                </dl>
            </div>

            <div class="fly-panel" style="padding: 20px 0; text-align: center;">
                <img src="/static/home/res/images/weixin.jpg" style="max-width: 100%;" alt="layui">
                <p style="position: relative; color: #666;">微信扫码联系 <span style="color: green;">社区鼻祖</span> 充值积分</p>
            </div>
        </div>
    </div>
</div>
<script>
    layui.use(['layer'], function () {
        let $ = layui.jquery,
            layer = layui.layer

        // let point = $("#fly-kiss").text();
        // console.log(point);
        // let cookieValue = document.cookie;
        // let arr = document.cookie.split("; ");
        // let arrTwo = arr[0].split("=");

        // if (arrTwo[1] == 'signInValue') {
        //     $('#LAY_signin').text('今日已签到成功');
        //     $('.fly-kiss').css('display', 'none');
        //     $('#LAY_signin').css({ 'background': 'gray' });
        //     $('#LAY_signin').attr('disabled', true);
        // }

        $('#LAY_signin').click(function () {
            // let point = $(".fly-kiss cate").val();
            let point = `{$SignPoint}`;
            // console.log(point);
            $.ajax({
                type: 'post',
                url: `{:url('home/User/sign')}`,
                data: {
                    point,
                    action: 'signIn'
                },
                dataType: 'json',
                success: function (res) {
                    if (res.code == 1) {
                        $('.fly-signin-days cite').text(res.data);
                        $('#LAY_signin').text('今日已经签到成功');
                        $('.fly-kiss').css('display', 'none');
                        $('#LAY_signin').css({
                            'background': '#FBFBFB',
                            'color': '#C9C9C9',
                            'border': '1px solid #e6e6e6',
                        });
                        $('#LAY_signin').attr('disabled', true);
                        // let expires = new Date();
                        // console.log(expires.getTime());
                        // expires.setTime(expires.getTime() + 1 * 24 * 60 * 60 * 1000);;
                        // document.cookie = "signIn=signInValue" + ";expires=" + expires.toGMTString();
                        layer.msg(res.msg)
                    } else {
                        layer.msg(res.msg)
                    }
                }
            });
        });
    })
</script>